package com.spn.blog.api.controller.article;

import com.spn.blog.common.vo.Result;
import com.spn.blog.service.article.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "类别模块")
@RestController
@RequestMapping("api/categorys")
public class CategoryController {

    @DubboReference
    private CategoryService categoryService;


    @ApiOperation(value = "获取 - 所有类别")
    @GetMapping
    public Result categories(){
        return categoryService.findAll();
    }

    @ApiOperation(value = "获取 - 所有类别详细信息")
    @GetMapping("detail")
    public Result categoriesDetail(){
        return categoryService.findAllDetail();
    }

    @ApiOperation(value = "获取 - 单个类别详细信息")
    @GetMapping("detail/{id}")
    public Result categoryDetailById(@PathVariable("id") Long id) {
        return categoryService.categoryDetailById(id);
    }
}
